//
//  TaskItemCell.m
//  chart
//
//  Created by 曾斌 on 16/3/24.
//  Copyright (c) 2016年 xu. All rights reserved.
//

#import "TSUserCell.h"
#import "TSUserModel.h"
#define MESSAGE_CELL_GAP 5.f
#define TIME_LABEL_WIDTH 160.f
#define SECTION_LABEL_WIDTH (currentDeviceWidth-TIME_LABEL_WIDTH-STATUS_LABEL_WIDTH-2*MESSAGE_CELL_GAP-2*MARGIN_LEFT)
#define STATUS_LABEL_WIDTH 80.f

@implementation TSUserCell{
    UILabel *nameLabel;
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self addNameLabel];
    }
    
    return self;
}


- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier isHeader:(BOOL) isHeader{
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self addNameLabel];
    }
    return self;
}

-(void)setRecycleHeadContent
{
    if (nameLabel) {
        [nameLabel setText:[NSString stringWithFormat:@"%@", @"姓名"]];
    }
    
}

- (void)addNameLabel
{
    nameLabel = [self createLabel:CGRectMake(MARGIN_LEFT, 0, TIME_LABEL_WIDTH, CGRectGetHeight(self.bounds)) TextAignment:NSTextAlignmentLeft];
    [self.contentView addSubview:nameLabel];
}

- (UILabel *)createLabel:(CGRect)frame TextAignment:(NSTextAlignment)alignment
{
    UILabel *label = [[UILabel alloc] initWithFrame:frame];
    [label setText:@""];
    label.textAlignment = alignment;
    [label setFont:FONT(12.f)];
    
    return label;
}

- (void)setModel:(TSUserModel *)model
{
    
    if (nameLabel) {
        [nameLabel setText:model.name?model.name:model.userName];
    }

}

@end
